package com.codingman.mybatisdemo5;

import java.io.IOException;
import java.io.InputStream;

import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSessionManager;

public class Demo1 {

	public static SqlSessionManager getSqlSessionManager() {
		InputStream is;
		try {
			is = Resources.getResourceAsStream("mybatis_config.xml");
			return SqlSessionManager.newInstance(is);
		} catch (IOException e) {
			e.printStackTrace();
		}
		return null;
	}

	public static void main(String[] args) {
		SqlSessionManager manager = Demo1.getSqlSessionManager();
		
		EmployeeMapper dao = manager.getMapper(EmployeeMapper.class);
		Employee e = dao.findById(101).get();
		System.out.println(e);
	}
}
